<?php

namespace App\Http\Controllers\admin;

use App\Dao\BaseDao;
use App\Dao\SciencesDao;
use App\Exceptions\SysExceptions;
use App\Services\Code;

class SciencesController extends BaseDao
{
    public function sciences(){
        if(getIsHasPage()){
            return Code::message('',200,SciencesDao::videos(request()->all()));
        }
        return  view('admin.sciences.sciences');
    }

    public function add(){
        if(isPost()){
            $params = request()->all();
            SciencesDao::videosCreate($params);
            return  Code::message('',200);
        }
        return view('admin.sciences.add');
    }


    /**
     * @throws SysExceptions
     */
    public function edit(){
        if(isPost()){
            $params = request()->all();
            SciencesDao::edit($params);
            return Code::message('',200);
        }
        $info = SciencesDao::info(request()->all());
        return view('admin.sciences.edit',[
            'info'=>$info
        ]);
    }


    public function delete(): array
    {
        SciencesDao::delete(request()->all());
        return Code::message('删除成功',200);
    }
}
